package com.hls.zfbai.modules.business.service;

import com.hls.zfbai.core.utils.HttpClientUtil;
import com.hls.zfbai.core.utils.SM2AndSM4Utils;
import com.hls.zfbai.modules.business.dao.ZfbAiMapper;
import com.hls.zfbai.modules.business.entity.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Slf4j
@Service
public class ZfbAiService {
    @Resource
    private ZfbAiMapper zfbAiMapper;
    /**
     * 挂号记录事件
     * @param ghjlParam
     * @return
     */
    public ZfbAiData ghjl(GhjlParam ghjlParam) {
        Map<String, Object> header = new HashMap<>();
        ZfbAiParam zfbAiParam = SM2AndSM4Utils.buildZfbAiParam(ghjlParam, header);
        String response = HttpClientUtil.postParams(SM2AndSM4Utils.REQ_URL, zfbAiParam, header);
        ZfbAiData zfbAiData = SM2AndSM4Utils.buildZfbAiData(response);
        return zfbAiData;
    }

    /**
     * 报告出具事件及回诊事件
     * @param bgcjParam
     * @return
     */
    public ZfbAiData bgcj(BgcjParam bgcjParam) {
        Map<String, Object> header = new HashMap<>();
        ZfbAiParam zfbAiParam = SM2AndSM4Utils.buildZfbAiParam(bgcjParam, header);
        String response = HttpClientUtil.postParams(SM2AndSM4Utils.REQ_URL, zfbAiParam, header);
        ZfbAiData zfbAiData = SM2AndSM4Utils.buildZfbAiData(response);
        return zfbAiData;
    }

    /**
     * 根据条码号获取检验报告信息
     * @param tmh
     * @return
     */
    public Map<String, Object> jybgcj(String tmh) {
        return zfbAiMapper.jybgcj(tmh);
    }

    /**
     * 根据申请单号获取检查报告信息
     * @param sqdh
     * @return
     */
    public Map<String, Object> jcbgcj(String sqdh) {
        return zfbAiMapper.jcbgcj(sqdh);
    }
}